package com.itheima.app.controller;

import com.itheima.app.manager.SoundManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class SoundController
{
    @Autowired
    SoundManager soundManager;
    //存储录音(发录音)
    @PostMapping("/peachblossom")
    public ResponseEntity setSound(MultipartFile soundFile) throws IOException {
        MultipartFile sound=soundFile;
        soundManager.save(sound);

        return ResponseEntity.ok(null);
    }

    /**
     * 取录音（接受语音）
     * @return
     */

    @GetMapping("/peachblossom")
    public ResponseEntity getSound()
    {
        return soundManager.getSound();
    }
}
